<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>getOut</title>
        <link href="../css/style.css" rel="stylesheet" type="text/css" />
        <link href="../css/form.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="../lib/jquery-1.7.1.min.js"></script>
        <script type="text/javascript" src="../lib/knockout-2.0.0.js"></script>
        <script type="text/javascript" src="../js/login_functions.js"></script>
        <script type="text/javascript" src="../js/addressValidation.js"></script>
    </head>
    <body>
        <div class="rapidxwpr floatholder">
          <?php $activePage="none";  include_once "Header.php"; ?>
            <div id="middle">
                <div id="error">
                    <?php
                    if (isset($_POST['submit'])) {
                        if ($_POST['city'] == '' ||
                                $_POST['state'] == '' || $_POST['zip'] == '' ||
                                $_POST['lat'] == 'error' || $_POST['long'] == 'error') {
                            echo("Update failed!. Please make sure you enter all the required information");
                        } else {
                            
                            $user = $_SESSION['user'];
                            $user->setLat($_POST['lat']);
                            $user->setLon($_POST['long']);
                            $user->setCity($_POST['city']);
                            $user->setState($_POST['state']);
                            $user->setZip($_POST['zip']);
                            
                            $result = $user->Update();
                            
                            if (is_string($result)) {
                                echo("Error:" . $result);
                            }
                            else
                                header('Location: MyAccount.php?update=success');
                        }
                    }
                    ?>
                </div>
                <form method="post" action="ChangeLocation.php" enctype="multipart/form-data">
                    <header id="header" class="info">
                        <h2>Change Location</h2>
                    </header>
                    <ul>
                        <li>
                            <label class="desc">
                                Address 
                                <span id="addrReq" class="req">*</span>
                                <img id="loading" class="hide" src="../images/loading.gif">
                            </label>
                            <div>
                                <span class="addr1">
                                    <input name="address" type="text" class="field text addr large"/>
                                    <label>Street Address</label>
                                    </br>
                                </span></br>
                                <span class="city">
                                    <input name="city" type="text" class="field text addr"/>
                                    <label>City</label>
                                </span>
                                <span class="state">
                                    <input name="state" type="text" maxlength="2" class="field text addr small">
                                        <label>State</label>
                                </span>
                                <span class="zip">
                                    <input name="zip" type="text" class="field text addr medsmall" maxlength="5"/>
                                    <label>Zip Code</label>
                                </span>
                                <input name="lat" type="hidden"/>
                                <input name="long" type="hidden"/>
                            </div>
                            <li>
                                <span>
                                    </br>
                                    <input name="submit" class="submit" type="submit" value="Save"/>
                                    <label>
                                        * Required fields
                                    </label>
                                </span>
                            </li>
                    </ul>
                </form>
            </div>
        </div>
        <div class="rapidxwpr floatholder">
            <div id="footer" class="clearingfix">
                <ul class="footermenu">
                    <li><a href="#">Events</a></li>
                    <li><a href="#">Spots</a></li>
                    <li><a href="#">Activities</a></li>
                    <li><a href="#">About</a></li>
                </ul>
            </div>
        </div>				
    </body>
</html>